package util

import (
	"encoding/json"
	"log"
	"time"
)

func GetTime() string {
	timestamp := time.Now().Unix()
	//格式化为字符串,tm为Time类型
	tm := time.Unix(timestamp, 0)
	timenow := tm.Format("2006-01-02 03:04:05")
	return timenow
}
func ToJson(data interface{}) string {
	jon := JSON{Data: data}
	bye, err := json.Marshal(jon)
	if err != nil {
		log.Println(err)
	}
	return string(bye)
}

type JSON struct {
	Data interface{}
}
type DataJson struct {
	Uids []int
	Data string
}

func StrToJson(data string) DataJson {
	be := []byte(data)
	var dataJson DataJson
	json.Unmarshal(be, &dataJson)
	return dataJson
}
